package com.example.benefitcommunity.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

/**
 * @author makejava
 */
@Configuration
public class WebMvcConfig implements WebMvcConfigurer {
    /**
     * 设置静态资源映射
     *
     * @param registry 注册
     */
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        // 设置上传的文件静态资源映射，application 里的 mvc 里也要设置下静态目录
        registry.addResourceHandler("/**").
                addResourceLocations("classpath:/static/").addResourceLocations("classpath:META-INF/resources/");
        registry.addResourceHandler("/swagger-ui/**").addResourceLocations("classpath:/META-INF/resources/webjars/springfox-swagger-ui/");
        registry.addResourceHandler("/upload/**").addResourceLocations("classpath:/upload/", "file:upload/");
    }
}
